package cn.codergege.demo.domain

import groovy.transform.Canonical
import org.hibernate.validator.constraints.NotEmpty

import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
import javax.persistence.Table
import javax.persistence.Transient
import javax.validation.constraints.Size

@Canonical
@Entity
@Table(name = "t_department")
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate
class Department {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
//    @GeneratedValue(generator = "ID_GENERATOR")
    Integer id

    @NotEmpty(message = "部门名称不能为空")
    @Size(min = 1, max = 50, message = "至少 1 个字符, 最多 50 个字符")
    String name

    @Column(name = "DESC", nullable = true)
    String desc

    @Transient
    String addition
}
